package com.seasun.xg.lamp.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.seasun.xg.lamp.repo.LogVo;

@RestController
@RequestMapping("/web")
public final class WebController {

	@Autowired
	private WebService service;

	@RequestMapping("/seqs/latest")
	public List<LogVo> latest() {
		return service.latest(10);
	}

	@RequestMapping("/seqs/latest/{count}")
	public List<LogVo> latest(@PathVariable int count) {
		return service.latest(count);
	}

	@RequestMapping("/seqs/search/{count}")
	public List<LogVo> search(@PathVariable int count,
			@RequestParam(value = "deviceId", defaultValue = "") String deviceId,
			@RequestParam(value = "localIp", defaultValue = "") String localIp,
			@RequestParam(value = "publicIp", defaultValue = "") String publicIp,
			@RequestParam(value = "level", defaultValue = "") String level,
			@RequestParam(value = "appName", defaultValue = "") String appName,
			@RequestParam(value = "appVersion", defaultValue = "") String appVersion,
			@RequestParam(value = "content", defaultValue = "") String content) {
		return service.search(count, deviceId, localIp, publicIp, level, appName, appVersion, content);
	}

	@RequestMapping("/seq/{seq}")
	public List<LogVo> get(@PathVariable String seq) {
		return service.get(seq);
	}

}
